* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

.header h1 {
    font-size: 3rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    font-weight: 600;
}

.header h1 i {
    margin-right: 15px;
    color: #ffd700;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

.main-content {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

/* 文件历史区域 */
.file-history {
    margin-bottom: 30px;
}

.file-history h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.2rem;
}



.file-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
}

/* 上传区域 */
.upload-section {
    margin-bottom: 30px;
}

.no-files {
    text-align: center;
    color: #999;
    font-style: italic;
}

.upload-area {
    border: 2px dashed #667eea;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    background: #f8f9ff;
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-area:hover {
    border-color: #5a6fd8;
    background: #f0f2ff;
}

.upload-area.dragover {
    border-color: #4c63d2;
    background: #e8ebff;
    transform: scale(1.02);
}

.upload-content {
    max-width: 400px;
    margin: 0 auto;
}

.upload-icon {
    font-size: 4rem;
    color: #667eea;
    margin-bottom: 20px;
}

.upload-text {
    font-size: 1.3rem;
    font-weight: 500;
    margin-bottom: 10px;
    color: #333;
}

.upload-desc {
    color: #666;
    margin-bottom: 30px;
    line-height: 1.5;
}

#fileInput {
    display: none;
}

.upload-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5a6fd8;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

/* 文件控制区域 */
.file-controls {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.select-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.control-buttons {
    display: flex;
    gap: 10px;
}

/* 结果显示区域 */
.result-section {
    margin-top: 30px;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
}

.result-tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.tab-btn {
    flex: 1;
    padding: 15px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: #666;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: white;
    color: #667eea;
    border-bottom: 3px solid #667eea;
}

.tab-btn:hover {
    background: #e9ecef;
}

.result-content {
    min-height: 300px;
    position: relative;
}

.result-panel {
    display: none;
    padding: 20px;
    min-height: 300px;
}

.result-panel.active {
    display: block;
}

/* 图片预览样式 */
.image-preview-container {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
    min-height: 400px;
}

.image-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed #e0e0e0;
    border-radius: 8px;
    background: #f8f9fa;
    position: relative;
    overflow: hidden;
}

.image-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.image-preview canvas {
    max-width: 100%;
    max-height: 100%;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.image-preview #previewPlaceholder {
    color: #999;
    font-style: italic;
    text-align: center;
}

/* 文本框样式 */
.text-boxes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: auto;
    display: none;
}

.text-box {
    position: absolute;
    border: 2px solid #ff4444;
    background: rgba(255, 68, 68, 0.1);
    pointer-events: none;
    transition: all 0.3s ease;
}

.text-box:hover {
    background: rgba(255, 68, 68, 0.2);
    border-color: #ff0000;
}

.text-box.highlight {
    border-color: #00ff00;
    background: rgba(0, 255, 0, 0.1);
    z-index: 10;
}

/* 优化的文本框样式 */
.text-input-box {
    position: absolute;
    border: 1px solid #007bff;
    background: rgba(0, 123, 255, 0.05);
    color: #2c3e50;
    font-size: 12px;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    padding: 1px 3px;
    box-sizing: border-box;
    transition: all 0.15s ease;
    pointer-events: auto;
    resize: none;
    outline: none;
    border-radius: 3px;
    z-index: 100;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
    line-height: 1.1;
    text-align: left;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* 单词级别的文本框 */
.text-box-word {
    border-width: 1px;
    background: rgba(0, 123, 255, 0.03);
}

/* 行级别的文本框 */
.text-box-line {
    border-width: 2px;
    background: rgba(0, 123, 255, 0.08);
}

.text-input-box:hover {
    border-color: #28a745;
    background: rgba(40, 167, 69, 0.08);
    box-shadow: 0 2px 4px rgba(0,0,0,0.12);
    cursor: pointer;
}

.text-input-box:focus,
.text-input-box:not([readonly]) {
    border-color: #ff6b6b;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.2);
    z-index: 200;
    cursor: text;
}

.text-input-box::placeholder {
    color: #999;
    font-style: italic;
}

/* 文本框提示信息样式 */
.coordinate-tip, .text-box-instruction {
    position: absolute;
    z-index: 1000;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    font-weight: 500;
    animation: fadeInSlide 0.3s ease-out;
}

/* 提示信息动画 */
@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 文本框容器优化 */
#textBoxes {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

#textBoxes .text-input-box {
    pointer-events: auto;
}

.preview-info {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    height: fit-content;
}

.preview-info h4 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.1rem;
    border-bottom: 2px solid #667eea;
    padding-bottom: 8px;
}

.preview-info p {
    margin-bottom: 10px;
    color: #666;
    line-height: 1.5;
}

.preview-info span {
    font-weight: 500;
    color: #333;
}

.preview-controls {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .image-preview-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .preview-info {
        order: -1;
    }
    
    .image-preview {
        min-height: 250px;
    }
}

.result-text {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    min-height: 200px;
    white-space: pre-wrap;
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #333;
    border: 1px solid #e0e0e0;
}

.result-panel pre {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    border: 1px solid #e0e0e0;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.result-actions {
    margin-top: 20px;
    display: flex;
    gap: 15px;
    justify-content: center;
}

/* 加载动画 */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    color: white;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #333;
    border-top: 5px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 文件项样式 */
.file-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 10px;
    background: white;
    transition: all 0.3s ease;
}

.file-item:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.file-item.uploaded {
    background: #f0f8ff;
    border-color: #4CAF50;
}

.file-item.selected {
    background: #fff3cd;
    border-color: #ffc107;
}

.file-item input[type="checkbox"] {
    margin-right: 10px;
}

.file-info {
    flex: 1;
    margin-right: 10px;
}

.file-name {
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
}

.file-meta {
    display: flex;
    gap: 15px;
    font-size: 0.85rem;
    color: #666;
}

.file-status {
    color: #28a745;
    font-weight: 500;
}

.remove-btn {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.remove-btn:hover {
    background: #c82333;
    transform: scale(1.1);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .main-content {
        padding: 20px;
    }
    
    .upload-area {
        padding: 30px 15px;
    }
    
    .upload-icon {
        font-size: 3rem;
    }
    
    .file-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .control-buttons {
        justify-content: center;
    }
    
    .result-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 100%;
        max-width: 200px;
    }
}